<template>
  <!-- 递归组件 -->
  <div>
    <Tree :data="dataTree"></Tree>
  </div>
</template>

<script setup lang='ts'>
import { ref, reactive } from 'vue'
import Tree from "./components/Tree.vue"

interface Tree {
  name: string,
  checked: boolean,
  children?: Tree[],
}

const dataTree = reactive<Tree[]>([
  {
    name: '1',
    checked: false,
    children: [
      {
        name: '1-1',
        checked: false
      },
      {
        name: '1-2',
        checked: true
      }
    ]
  },
  {
    name: '2',
    checked: false
  },
  {
    name: '3',
    checked: false,
    children: [
      {
        name: '3-1',
        checked: false,
        children: [
          {
            name: '3-1-1',
            checked: false
          },
          {
            name: '3-1-2',
            checked: false
          }
        ]
      }
    ]
  }
])

</script>

<style scoped lang='less'>
@border: #ccc;

.card {
  border: 1px solid @border;
}
</style>